<?php get_header(); ?>

<?php 

    $canon_options_post = get_option('canon_options_post');

    // SET STYLE 
    $style = $canon_options_post['homepage_blog_style'];

    // BUILD EXCLUDE ARRAY
    $results_exclude_posts = get_posts(array(
        'numberposts'       => -1,
        'meta_key'          => 'cmb_hide_from_archive',
        'meta_value'        => 'checked',
        'orderby'           => 'post_date',
        'order'             => 'DESC',
        'post_type'         => 'any',
        'suppress_filters'  => true,
    ));
    if (count($results_exclude_posts) > 0) {
        for ($i = 0; $i < count($results_exclude_posts); $i++) {  
            $exclude_array[$i] = $results_exclude_posts[$i]->ID;
        }   
    } else {
        $exclude_array = array();   
    }

    // to make pagination work on page if used as static homepage
    if (get_query_var('paged')) {
        $paged = get_query_var('paged'); 
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page'); 
    } else {
        $paged = 1; 
    }
    
    $args = array(
        'post_status'       => 'publish',
        'orderby'           => 'date',
        'order'             => 'DESC',
        'paged'             => $paged,
        'post__not_in'      => $exclude_array
    );

    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query($args); 

?>

         <!-- Start Main Body -->
        <div class="main-container">
            <div class="main wrapper clearfix">
                
                                
                <!-- Start Main Content -->
                <div class="main-content<?php if ($style != "sidebar") { echo " full"; } ?>">
                    <div class="clearfix">
                        

                        <?php 

                            if ($style == "full") {

                                get_template_part('inc/templates/template_blog_full');

                            } elseif ($style == "sidebar") {

                                get_template_part('inc/templates/template_blog_sidebar');

                            } else {

                                get_template_part('inc/templates/template_blog_neat');

                            }

                        ?>

        <!-- NB: wrapper containers are ended in template -->
		
<?php get_footer(); ?>
